﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ef.Repository.Infrastructure
{
    public class DatabaseFactory : Disposable, IDatabaseFactory
    {

        private MyContext dataContext;

        public MyContext GetContext()
        {
            return dataContext ?? (dataContext = new MyContext());
        }

        protected override void DisposeCore()
        {
            if (dataContext != null)
            {
                dataContext.Dispose();
            }
        }

    }
}
